<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />

		<style>
			* {
				padding: 0px;
				margin: 0px;
				font-family: "微软雅黑";
			}
			/*公用的css样式*/
			
			.mui-content {
				position: absolute;
				width: 100%;
				height: 100%;
				background: url(images/loginV2/background.png)no-repeat;
				background-size: 100%100%;
			}
			
			.public-white-text {
				color: #fff;
			}
			
			.public-float-left {}
			
			.public-clear-both {
				clear: both;
			}
			
			.public-btn-bgcolor {
				/*background: #00AAEE;
				color: #4AC3F3;
				border: 0px;*/
			}
			
			.public-content-padding {
				padding: 0px 10px;
			}
			
			.public-content-margin-top {
				margin-top: 10px;
			}
			
			.login-content {
				padding: 0px 0px;
			}
			
			.login-content-box {
				padding: 0px 10px;
			}
			
			.login-content-logo p {
				text-align: center;
			}
			
			.login-content-logo p img {
				margin-top: 35%;
				width: 75%;
				border-radius: 10px;
			}
			
			.login-content-login-div {
				text-align: center;
			}
			
			.login-content-login-div-center {}
			
			.login-content-login-div-center input {
				width: 75%;
				height: 45px;
				padding: 10px 10px;
				text-align: center;
				border-radius: 40px;
				font: arial
			}
			
			.login-content-login-div-left,
			.login-content-login-div-right {
				margin-left: 15%;
				color: #888;
			}
			
			.login-content-login-div-left {
				display: inline-block;
				width: 70px;
			}
			
			.login-content-login-div-right {
				float: center;
				color: #d8d8d8;
			}
			
			.login-btn {
				background-image: url(images/loginV2/loginbtn.png);
				background-repeat: no-repeat;
				background-size: 100% 100%;
				width: 75%;
				height: 45px;
				padding: 10px 0px;
			}
			
			.login-content-login p {
				text-align: center;
				font-size: 13px;
			}
			
			.login-content-login p a {
				color: #6D7FA4;
			}
			
			.login-content-login .register {
				position: absolute;
				bottom: 20px;
				left: 50%;
				margin-left: -15px;
				font-size: 18px;
			}

			#help {
				text-align: center;
				font-size: 14px;
				color: #666;
			}
			
			#help a {
				color: #666;
			}

		</style>
	</head>

	<body class="login-content">
		<div class="mui-content = login-content-box">
			<div class="login-content-logo">
				<p><img src="images/loginV2/logo.png" /></p>
			</div>
			<div style="text-align: center;font-size: 20px;;">
				劳务工人实名认证平台(内部员工)
			</div>
			<div class="login-content-login" style="margin-top: 30%;">
				<form>

					<div class="login-content-login-div">

						<div class="login-content-login-div-center public-float-left">
							<input type="text" placeholder="请输入用户名" />
						</div>

					</div>
					<div class="login-content-login-div">

						<div class="login-content-login-div-center public-float-left">
							<input type="password" placeholder="请输入登陆密码" />
						</div>

					</div>
				</form>
				<div style="text-align: center;margin-top:12%;">
					<button class="public-btn-bgcolor login-btn" id="btn" Style="background-color: Transparent; 
							border-style :none;">
						</button>

				</div>

				<div style="text-align: center;margin-top:5%;">
					<button class="public-btn-bgcolor mui-btn-link " style="font-size:medium;color:black;"  id="yanzhengma">
						<u>劳务工人点击手机号验证码登录</u>
					</button>

				</div>
			</div>
		</div>
		<script src="js/iBase.js"></script>
		<script>
			iBase.init();

			iBase.closeStartPage();

			iBase.showWaiting();
			iBase.dblclickExit();
			localStorage.setItem('request_url', "http://192.168.199.102:8052");
			var request_url = localStorage.getItem('request_url');

			mui.plusReady(function() {
				plus.navigator.setFullscreen(true);
				var height1 = plus.android.invoke(plus.android.currentWebview(), "getHeight"); //高度物理分辨率
				var height2 = plus.screen.resolutionHeight; //高度逻辑分辨率
				var top = plus.navigator.getStatusbarHeight(); //状态栏高度
				document.getElementsByClassName("mui-content")[0].style.height = (height2) + "px";

				checkVersion();

				checkislogin();

			});

			function checkVersion() {
				mui.plusReady(function() {
					plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
						//console.log(wgtinfo.version);
						var request_url = localStorage.getItem('request_url');
						// 原理 -> 请求数据库 查看是否有新版本 -> 返回版本信息
						iBase.get({
							url: request_url + '/Common_Permission/DownLoad/GetLatestReleaseMobileClientVersion?type=yezhu',
							data: {},
							succFn: function(data) {
								var json = JSON.parse((data));
								if(json.data.VersionCode == wgtinfo.version) {
									//iBase.prompt('没有新版本');
								} else {

									iBase.confirm({
										title: '提示',
										content: '发现新版本，是否更新？',
										callback: function(data) {
											if(data) {
												iBase.openUrl(json.data.Url);
											}
										}
									});
								}
							}
						});
					});
					//console.log(plus.runtime.version+"\n内核版本号："+plus.runtime.innerVersion);
				});
			}

			function checkislogin() {

				local_username = localStorage.getItem('local_username');
				if(local_username == '' || local_username == null || local_username == 'null'
				||local_username=='laowugongren') {
					iBase.closeWaiting();
					return;
				}
				mui.plusReady(function() {
					//var clientinfo = plus.push.getClientInfo();
					var type = "";
					var version = plus.os.version;
					if(mui.os.android) {
						type = 'android';
					} else {
						type = 'iphone';
					}
					iBase.post({
						url: request_url + '/api/Permission',
						data: {
							action: "checkislogin",
							username: local_username,
							token: "",
							clientid: "",
							appid: "",
							appkey: "",
							type: type,
							version: version
						},
						succFn: function(data) {
							//console.log(data)
							var json = JSON.parse(eval(data));
							if(json.success) {
								//localStorage.setItem('server_userInfo', data);
								iBase.sendNotice('root', 'OpenServerUrl', {
									url: '/Mobile_Index/Main/IndexV2',
									id: 'Mobile_Index'
								});
							} else {
								iBase.closeWaiting();
							}

						}
					});

				});

			}
			// 登录相关代码
			// 获得元素
			var btn = iBase.id('btn');
			var input = iBase.tagName('input');
			input['0'].value = localStorage.getItem('local_username');
			//登录操作
			iBase.click(btn, function() {
				// 获取账号和密码
				var username = input['0'].value;
				var password = input['1'].value;

				//判断
				if(username == '') {
					iBase.prompt('帐号不能为空');
					return;
				}

				// 判断是不是数字，判断收个字符是不是1开头
				if(password == '') {
					iBase.prompt('密码不能为空');
					return;
				}

				//显示等待框
				iBase.showWaiting();

				//请求数据库

				iBase.post({
					url: request_url + '/api/Permission',
					data: {
						action: "login",
						user: username,
						pass: password

					},
					succFn: function(data) {

						setTimeout(function() {
							var json = JSON.parse(eval(data));
							if(json.success == true) {
								iBase.prompt('登录成功');
								localStorage.setItem('local_username', username);
								//跳转到相应的页面
								iBase.sendNotice('root', 'OpenLocalUrl', {
									url: request_url + '/Mobile_Index/Main/IndexV2',
									id: 'Mobile_Index'
								});

							} else {
								iBase.prompt('密码错误');
							}

						}, 1000);

					}
				});

			});


			//登录操作
			iBase.click(iBase.id('yanzhengma'), function() {
				// 获取账号和密码
						setTimeout(function() {
							localStorage.setItem('local_username', 'laowugongren');
								//跳转到相应的页面
								iBase.newInterface({
									url: request_url + '/Laowugongren_Index/LaowugongrenAuth/Login',
									id: 'LaowugongrenLogin'
								});
								/*iBase.sendNotice('root', 'OpenLocalUrl', {
									url: request_url + '/Laowugongren_Index/LaowugongrenAuthController/Login',
									id: 'LaowugongrenLogin'
								});*/

						}, 1000);

			});
			
			
			iBase.receiveNotice('OpenServerUrl', function(msg) {
				//var json = JSON.parse(msg.detail);
				var url = msg.detail.url;
				if(msg.detail.url.startsWith("/")) {
					url = request_url + url;
				}
				iBase.newInterface({
					url: url,
					id: msg.detail.id,
					extras: msg.detail.extras
				});
			});
			iBase.receiveNotice('OpenLocalUrl', function(msg) {
				//var json = JSON.parse(msg.detail);
				var url = msg.detail.url;

				iBase.newInterface({
					url: url,
					id: msg.detail.id,
					extras: msg.detail.extras
				});
			});

			iBase.receiveNotice('resetAPPData', function() {
				if(config.debug) {
					console.log('resetAPPData')
				}
				localStorage.setItem('local_username', "");

			});

			iBase.receiveNotice('ResetUserInfo', function(msg) {
				//var json = JSON.parse(msg.detail);
				var type = msg.detail.type;
				if(type == 'logout') {
					localStorage.removeItem('local_username');
				} else if(type == 'updateusername') {
					localStorage.setItem('local_username', msg.detail.username);
				}

			});

			iBase.dblclickExit();
		</script>
	</body>

</html>